function text_copy_event(data) {
  var value =
    typeof data == "object"
      ? data.currentTarget.dataset.value || null
      : data || null;
  if (value != null) {
    uni.setClipboardData({
      data: value,
      success(res) {
        uni.getClipboardData({
          success(res) {
            uni.showToast({
              icon: "success",
              title: "复制成功",
              duration: 3000,
            });
          },
        });
      },
    });
  } else {
    this.showToast("复制内容为空");
  }
}

function getYear(timestamp) {
  let time = new Date(timestamp);
  let year = time.getFullYear();
  let month = time.getMonth() + 1;
  let date = time.getDate();
  // let hours = time.getHours()
  // let minute = time.getMinutes()
  // let second = time.getSeconds()

  if (month < 10) {
    month = "0" + month;
  }
  if (date < 10) {
    date = "0" + date;
  }
  // if (hours < 10) {
  //     hours = '0' + hours
  // }
  // if (minute < 10) {
  //     minute = '0' + minute
  // }
  // if (second < 10) {
  //     second = '0' + second
  // }
  // return year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second
  return year + "-" + month + "-" + date + " ";
}

export {
  text_copy_event,
  getYear,
};
